#include <iostream>
#include <string>
using namespace std;
class Solution {
  public:
    int StrToInt(string str) {
        if(str.size()==0) return 0;
        int num = 0;
        auto it = str.begin();
        int flag = 1;
        while (it != str.end()) {
            if (*it == '-') {
                flag = -1;
                ++it;
                continue;
            }
            if (*it == '+') {
                ++it;
                continue;
            }
            if(!isdigit(*it)) return 0; 
            num = num * 10;
            num += ((*it) - '0');
            ++it;
        }
        return num*flag;
    }
};